#ifndef MSG_QUEUE_H
#define MSG_QUEUE_H

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdbool.h>

struct message_queue;
typedef int (*message_queue_cb)(struct message_queue *);

struct message_queue {
	uint32_t cmd;
	size_t len;
	void *data;
	/* uint64_t param[20];  //20 * 8 = 160字节 */
	/* message_queue_cb cb; */
	struct message_queue *next;
};

struct send_msg
{
	char *topic;
	int partid;
	void *data;
};

void                   skynet_globalmq_init();
void skynet_globalmq_push(struct message_queue * queue);
struct message_queue * skynet_globalmq_pop();
int globalmq_sleep();

struct spinlock {
	int lock;
};
struct normal_queue {
	struct message_queue *head;
	struct message_queue *tail;
	struct spinlock lock;
};
void normal_queue_init(struct normal_queue *q);
void normal_queue_push(struct normal_queue *q, struct message_queue * queue);
struct message_queue *normal_queue_pop(struct normal_queue *q);
struct message_queue *normal_queue_getmq(struct normal_queue *q);
bool is_normal_queue_empty(struct normal_queue *q);

#endif /* MSG_QUEUE_H */
